﻿#ifndef MP3DECODE_H
#define MP3DECODE_H

#include <QObject>

class LoopBuffer;

class Mp3Decode : public QObject
{
    Q_OBJECT
public:
    explicit Mp3Decode(const QString &file,QObject *parent = nullptr);
    ~Mp3Decode();
    void setParam(int dstSampleRate, LoopBuffer *buffer);
    int getSrcChannels() const;
    int getSrcSampleRate() const;
    int getSrcFormat() const;
signals:
    void sgPCMData(QByteArray array);
public slots:
    void run();
    void stop();
private:
    LoopBuffer *m_buffer = nullptr;

    int m_dstSampleRate = 0;

    // meta info
    int m_srcSampleRate = 0;
    int m_srcChannels = 0;
    int m_srcFormat = 0;
    int m_srcDuration = 0;

    QString m_file;

    bool m_isStop = false;

    void parseMp3MetaInfo();
};

#endif // MP3DECODE_H
